/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package boundary.display;

import entity.Client;
import entity.Entity;

/**
 *
 * @author Juan
 */
public class PPersonDisplay extends EntityDisplayPanel {

    /**
     * Creates new form Panel
     */
    public PPersonDisplay() {
        initComponents();
    }

    @Override
    public void setCurrentEntity(Entity entity) throws IllegalArgumentException {
        if (entity instanceof Client) {
            Client currentClient = (Client) entity;
            if (currentClient.getType() == Client.PERSON) {
                currentEntity = entity;
                TFName.setText(currentClient.getName());
                LAbbreviation.setText(currentClient.getAbbreviation());
                TFIdNum.setText(currentClient.getIdNum());
                TFCity.setText(currentClient.getCity());

                pAddresses.setAdresses(currentClient.getAddresses());
                pEmails.setEmails(currentClient.getEmails());
                pPhoneNumbers.setPhoneNumbers(currentClient.getPhoneNumbers());

                String idType = currentClient.getIdType();
                if (idType.equals(Client.PASSPORT)) {
                    TFIdType.setText("Pasaporte");
                } else {
                    TFIdType.setText(idType);
                }
            } else {
                throw new IllegalArgumentException("The Client to be displayed is not a Person.");
            }
        } else {
            throw new IllegalArgumentException("The object to be displayed is not a Client.");
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        TFName = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        TFIdNum = new javax.swing.JTextField();
        TFIdType = new javax.swing.JTextField();
        pPhoneNumbers = new components.panels.PPhoneNumbers();
        pAddresses = new components.panels.PAddresses();
        jLabel3 = new javax.swing.JLabel();
        TFCity = new javax.swing.JTextField();
        BReturn = new javax.swing.JButton();
        pEmails = new components.panels.PEmails();
        jLabel4 = new javax.swing.JLabel();
        LAbbreviation = new javax.swing.JLabel();

        jLabel1.setText("Nombre:");

        TFName.setEditable(false);

        jLabel2.setText("Identificación:");

        TFIdNum.setEditable(false);

        TFIdType.setEditable(false);

        jLabel3.setText("Ciudad:");

        TFCity.setEditable(false);

        BReturn.setText("Cerrar");
        BReturn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BReturnActionPerformed(evt);
            }
        });

        jLabel4.setText("Abreviatura:");

        LAbbreviation.setText("AAA");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(TFName, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                    .addComponent(TFCity)
                    .addComponent(pAddresses, javax.swing.GroupLayout.DEFAULT_SIZE, 464, Short.MAX_VALUE)
                    .addComponent(pPhoneNumbers, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(pEmails, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel4)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(LAbbreviation))
                            .addComponent(TFIdType, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(TFIdNum, javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup()
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jLabel1)
                                        .addComponent(jLabel2))
                                    .addGap(302, 302, 302)))
                            .addComponent(BReturn))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(TFName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(LAbbreviation))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(TFIdType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(TFIdNum, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(TFCity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(pPhoneNumbers, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(pEmails, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(pAddresses, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(BReturn)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void BReturnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BReturnActionPerformed
        buttonTabComponent.closeTab();
    }//GEN-LAST:event_BReturnActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BReturn;
    private javax.swing.JLabel LAbbreviation;
    private javax.swing.JTextField TFCity;
    private javax.swing.JTextField TFIdNum;
    private javax.swing.JTextField TFIdType;
    private javax.swing.JTextField TFName;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private components.panels.PAddresses pAddresses;
    private components.panels.PEmails pEmails;
    private components.panels.PPhoneNumbers pPhoneNumbers;
    // End of variables declaration//GEN-END:variables
}
